package cn.wolfcode.trip.app.web.controller;

import cn.wolfcode.trip.app.util.UserContext;
import cn.wolfcode.trip.base.domain.User;
import cn.wolfcode.trip.base.query.TravelQueryObject;
import cn.wolfcode.trip.base.service.INiceDetailService;
import cn.wolfcode.trip.base.service.IStrategyCommentService;
import cn.wolfcode.trip.base.service.ITravelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;

/**
 *@Discription 攻略点赞管理界面

 *@Params

 *@Return

 *@Authod  黄照伟

 *@CreationTime  2019/3/11 16:28

 *@change

 */
@RestController
@RequestMapping("/assist")
public class AssistController {
    @Autowired
    private IStrategyCommentService iStrategyCommentService;

    @Autowired
    private ITravelService iTravelService;

    @Autowired
    private INiceDetailService iNiceDetailService;


    @GetMapping("/allCount")
    public Object getAllCount() {
        User user = UserContext.getCurrentUser();
        HashMap<String, Object> map = new HashMap<>();

        int travelCount = iNiceDetailService.getAssistCount(user.getId());

        int commentCount = iStrategyCommentService.getAssistCount(user.getId());
        map.put("travelCount", travelCount);
        map.put("commentCount", commentCount);
        return map;
    }
    //评论分页
    @GetMapping("travelInfo")
    public Object getTravelInfo(TravelQueryObject qo) {
        User user = UserContext.getCurrentUser();
        qo.setPageSize(5);
        qo.setAuthorId(user.getId());
        return iTravelService.selectTravelAndUserByAuthorId(qo);
    }


}
